<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/weui.css">
    <script src="__STATIC__/js/zepto.min.js" type="text/javascript"></script>
    <script src="__STATIC__/js/picker.js" type="text/javascript"></script>
    <script src="__STATIC__/js/picker-city.js" type="text/javascript"></script>
    <script src="__STATIC__/js/select.js" type="text/javascript"></script>
</head>

<body class="fff">
	<div>
	    <form id="teacher_infoForm" class="easyui-form" method="post" data-options="novalidate:true">
	    	<input type="hidden" name="ID" id="ID" value="<?php echo arrayEq('ID',$detail);?>"/>
	    	<table cellpadding="5" width="100%">
	    		<tr>
	    			<td width="10%">姓名</td>
	    			<td width="40%"><input class="easyui-textbox" type="text" name="姓名" value="<?php echo arrayEq('姓名',$detail);?>" data-options="required:true"></input></td>
	    			<td width="10%">年级号</td>
	    			<td width="40%"><input class="easyui-combobox" name="年级号" value="<?php echo arrayEq('gradeKey',$detail);?>" data-options="
					url:'/compent/Util/gradeList',
					method:'get',
					valueField:'value',
					textField:'text',
					panelHeight:'auto'"></td>
	    		</tr>
	    		<tr>
	    			<td>任教学科:</td>
	    			<td><input class="easyui-combobox" name="任教学科ID" value="<?php echo arrayEq('任教学科ID',$detail);?>" data-options="
					url:'/compent/Util/subjectList',
					method:'get',
					valueField:'value',
					textField:'text',
					panelHeight:'auto'"></td>
	    			<td>身份证号</td>
	    			<td><input class="easyui-textbox" type="text" name="身份证号" value="<?php echo arrayEq('身份证号',$detail);?>" data-options="required:true"></td>
	    		</tr>
	    		<tr>
	    			<td>手机号</td>
	    			<td><input class="easyui-numberbox" name="手机号" value="<?php echo arrayEq('手机号',$detail);?>" data-options="required:true"></td>
	    			<td>登录密码</td>
	    			<td><input class="easyui-passwordbox" name="登录密码" value="<?php echo arrayEq('登录密码',$detail);?>" required></td>
	    		</tr>
	    		<tr>
	    			<td>性别</td>
	    			<td><select style="width: 150px;" class="easyui-combobox" name="性别" id="性别" required>
	    				<option value="">请选择</option>
	    				<option value="男">男</option>
	    				<option value="女">女</option>
	    			</select></td>
	    			<td>出生日期</td>
	    			<td><input class="easyui-datebox" name="出生日期" value="<?php echo arrayEq('出生日期',$detail);?>"></td>
	    		</tr>
	    		<tr>
	    			<td>是否签到</td>
	    			<td><select style="width: 150px;" class="easyui-combobox" name="签到" id="签到">
	    				<option value="1">是</option>
	    				<option value="0">否</option>
	    			</select></td>
	    			<td>身份</td>
	    			<td><input class="easyui-combobox" name="职位" value="<?php echo arrayEq('职位',$detail);?>" data-options="
					valueField:'ID',
                    textField:'POSITION',
                    groupField:'DEPART',
                    method:'get',
                    url: '/compent/Util/organizeDepart',
                    multiple:true,
                    editable:false"></td>
	    		</tr>
	    		<tr>
	    			<td>职称</td>
	    			<td><input class="easyui-textbox" type="text" name="职称" value="<?php echo arrayEq('职称',$detail);?>"></input></td>
	    			<td>籍贯</td>
	    			<td><input class="form-control" name="籍贯" id="籍贯" value="<?php echo arrayEq('籍贯',$detail);?>"></td>
	    		</tr>
	    		<tr>
	    			<td>民族</td>
	    			<td><select class="easyui-combobox" style="width: 150px;" name="民族" id="民族" value="<?php echo arrayEq('民族',$detail);?>"></select></td>
	    			<td>政治面貌</td>
	    			<td><select style="width: 150px;" class="easyui-combobox" name="政治面貌" id="政治面貌">
	    				<option value="">请选择</option>
	    				<option value="男">群众</option>
	    				<option value="女">共产党员</option>
	    				<option value="女">共青团员</option>
	    				<option value="女">其它</option>
	    			</select></td>
	    		</tr>
	    		<tr>
	    			<td>居住地址</td>
	    			<td><input class="form-control" name="居住地址" id="居住地址"> <input class="form-control" name="liveAddrDesc" id="liveAddrDesc" style="width:200px;" placeholder="请输入居住详细地址（具体到门牌）"></td>
	    		</tr>
	    		<tr>
	    			<td>入党团时间</td>
	    			<td><input class="easyui-datebox" name="入党团时间" value="<?php echo arrayEq('入党团时间',$detail);?>"></td>
	    			<td>户口性质</td>
	    			<td><select class="easyui-combobox w150" name="户口性质" id="户口性质">
	    				<option value="">请选择</option>
	    				<option value="农业">农业</option>
	    				<option value="非农业">非农业</option>
	    			</select></td>
	    		</tr>
	    		<tr>
	    			<td>婚姻状况</td>
	    			<td><select class="easyui-combobox w150" name="婚姻状况" id="婚姻状况">
	    				<option value="">请选择</option>
	    				<option value="已婚">已婚</option>
	    				<option value="未婚">未婚</option>
	    				<option value="离婚">离婚</option>
	    			</select></td>
	    			<td>毕业参加工作时间</td>
	    			<td><input class="easyui-datebox" name="毕业参加工作时间" value="<?php echo arrayEq('毕业参加工作时间',$detail);?>"></td>
	    		</tr>
	    		<tr>
	    			<td>大学专业</td>
	    			<td><input class="easyui-textbox" type="text" name="大学专业" value="<?php echo arrayEq('大学专业',$detail);?>"></input></td>
	    			<td>是否正编教师</td>
	    			<td><select class="easyui-combobox w150" name="是否正编教师" id="是否正编教师">
	    				<option value="">请选择</option>
	    				<option value="是">是</option>
	    				<option value="否">否</option>
	    			</select></td>
	    		</tr>
	    		<tr>
	    			<td>是否有普通话证</td>
	    			<td><select class="easyui-combobox w150" name="是否有普通话证" id="是否有普通话证">
	    				<option value="">请选择</option>
	    				<option value="是">是</option>
	    				<option value="否">否</option>
	    			</select></td>
	    			<td>是否具备心理ABC证</td>
	    			<td><select class="easyui-combobox w150" name="是否具备心理ABC证" id="是否具备心理ABC证">
	    				<option value="">请选择</option>
	    				<option value="是">是</option>
	    				<option value="否">否</option>
	    			</select></td>
	    		</tr>
	    		<tr>
	    			<td>其他获得资格证书</td>
	    			<td><input class="easyui-textbox" name="其他获得资格证书" value="<?php echo arrayEq('其他获得资格证书',$detail);?>" data-options="multiline:true" style="height:60px"></input></td>
	    			<td>曾获得荣誉</td>
	    			<td><input class="easyui-textbox" name="曾获得荣誉" value="<?php echo arrayEq('曾获得荣誉',$detail);?>" data-options="multiline:true" style="height:60px"></input></td>
	    		</tr>
	    	</table>
	    </form>
	    <div class="m20 tnc">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">确认提交</a>
	    </div>
	</div>
	<script type="text/javascript">
		$(function() {
			$('#性别').combobox("setValue", "<?php echo arrayEq('性别',$detail);?>");
			$('#民族').combobox("setValue", "<?php echo arrayEq('民族',$detail);?>");
			$('#政治面貌').combobox("setValue", "<?php echo arrayEq('政治面貌',$detail);?>");
			$('#户口性质').combobox("setValue", "<?php echo arrayEq('户口性质',$detail);?>");
			$('#婚姻状况').combobox("setValue", "<?php echo arrayEq('婚姻状况',$detail);?>");
			$('#是否正编教师').combobox("setValue", "<?php echo arrayEq('是否正编教师',$detail);?>");
			$('#是否有普通话证').combobox("setValue", "<?php echo arrayEq('是否有普通话证',$detail);?>");
			$('#是否具备心理ABC证').combobox("setValue", "<?php echo arrayEq('是否具备心理ABC证',$detail);?>");
		})
		initLiveAddr("<?php echo arrayEq('居住地址',$detail);?>")
		$("#籍贯").cityPicker({
	        title: "请选择省市区"
	    });
	    $("#居住地址").cityPicker({
	        title: "请选择省市区"
	    });
	    initNation("teacher_info");
	    function initLiveAddr(v) {
			if(!v) return;
			var array = v.split(",");
			$("#居住地址").val(array[0]);
			$("#liveAddrDesc").val(array[1]);
		}
		function submitForm() {
			var data = $.serializeObject($("#teacher_infoForm"));
			if(!data.姓名) {
				$.messager.alert('提醒','姓名不能为空','info');
				return false;
			}
			else if(!data.身份证号) {
				$.messager.alert('提醒','身份证号不能为空','info');
				return false;
			}
			else if(!data.登录密码) {
				$.messager.alert('提醒','登录密码不能为空','info');
				return false;
			}
			else if(!data.性别) {
				$.messager.alert('提醒','性别不能为空','info');
				return false;
			}
			else if(!data.手机号) {
				$.messager.alert('提醒','手机号不能为空','info');
				return false;
			}
			if(data.居住地址 && data.liveAddrDesc) {
				data.居住地址 += "," + data.liveAddrDesc;
			}else {
				if(data.居住地址 || data.liveAddrDesc) {
					$.messager.alert('提醒','居住地址填写完整','info');
				return false;
				}
			}
			delete data.liveAddrDesc;
			if(!data.ID) delete data.ID;
			$.ajax({
				url: "{:url('TeacherManage/addUpdate')}?",
				type: 'POST',
				data: data
			}).done(function(resp) {
				if(resp=='000'){
				    $.messager.show({title:'操作提示', msg:"提交成功"});
				    setTimeout(function() {
				    	openTab('教师信息管理', "teacher_manage");
				    	closeTab(data.ID ? "修改教师信息" : "新增教师");
			    	}, 1000)
				}
			}).fail(function() {
				$('#msg').html('error,发生错误请及时联系管理员!');
			});
		}
	</script>
</body>
</html>